// pages/instdetails/instdetails.js
var util = require("../../utils/util.js")
var api = require("../../utils/api.js")
var app = getApp();
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
       user_map:[],
		isfollow:0,
		accountid:0,
		id: 0,
		phone:'',
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
        var that=this
		that.setData({
			id: options.id
		})
		var data={id:options.id}
		var url = app.u.HOME_URL + app.u.ORGEN_INFO
		api.requestUrl(data, url).then(res => {
			WxParse.wxParse('mainintro', 'html', res.data.mainintro, this, 5);
			that.setData({
				user_map: res.data,
				phone: res.data.phone
			})
		})
	},
	contact: function () {
		var that=this
		wx.makePhoneCall({
			phoneNumber: that.data.phone,
		})
	},
    follow:function(){
		var that = this
		wx.getStorage({
			key: 'userInfo',
			success: function (res) {
				 that.setData({
				 	accountid:res.data.id
				 })
				var data = { account_id: that.data.accountid, id: that.data.id, type: 'org' }
				var url = app.u.HOME_URL + app.u.FOLLOW
				api.requestUrl(data, url).then(res => {
					that.setData({
						isfollow: res.data
					})
				})
			}, 
		})
	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {
		wx.showShareMenu({
			withShareTicket: true
		})
	},
})